<!DOCTYPE html>
<html>
    <head>
        <title>sessionStorage</title>
    </head>
    <body>
        <h1>Hello, world!</h1>
        <button onclick="saveData()">save data</button>
        <button onclick="deleteData()">clear data</button>
        <button onclick="readData()">read data</button>
        <button onclick="deleteAll()">DeleteAll</button>
    </body>
    <script type="text/javascript">
        let p={name:'张三', age: 18}
        function saveData() {
            sessionStorage.setItem('name', 'Tom');
            sessionStorage.setItem('age', 18);
            sessionStorage.setItem('person', JSON.stringify(p));
        }
        function deleteData() {
            sessionStorage.removeItem('name');
        }
        function readData() {
            console.log(sessionStorage.getItem('person'));
        }
        function deleteAll() {
            sessionStorage.clear();
        }
    </script>
</html>
